package main

import (
	"fmt"
	"gorm-study/src/pkg/student/models"
	"gorm-study/src/pkg/utils/dbutil"
)

func main() {
	var zhoujiu models.Student
	result := dbutil.DB.Where("name = ?", "周九").First(&zhoujiu)
	fmt.Printf("Save 前查询周九，返回数量：%v \n", result.RowsAffected)
	fmt.Printf("Save 前查询周九：%+v \n", zhoujiu)

	zhoujiu.Age++
	email := "zhoujiu@huya.com"
	zhoujiu.Email = &email
	result = dbutil.DB.Save(&zhoujiu)
	fmt.Printf("Save 时 result.RowsAffected：%v \n", result.RowsAffected)

	result = dbutil.DB.Where("name = ?", "周九").First(&zhoujiu)
	fmt.Printf("Save 后查询周九，返回数量：%v \n", result.RowsAffected)
	fmt.Printf("Save 后查询周九：%+v \n", zhoujiu)
}
